<?php
$this->breadcrumbs = array(
	'Roles and Permissions' => array('roles/index'),
	$role->description => array('roles/view', 'role_id' => $role->name),
	'Update'
);
?>
<div class="main-title">
    <h1><?php echo $role->description; ?></h1>
</div>
<div class="flat_area">
	<?php
	$form = $this->beginWidget('PsActiveForm', array(
		'id' => 'ps-new-role-form',
		'enableAjaxValidation' => false,
		'enableClientValidation' => true,
		'clientOptions' => array(
			'inputContainer' => 'tr',
			'validateOnSubmit' => true,
		),
		'htmlOptions' => array(
		)
			));
	?>
	<div class="section grid_16">
		<div class="block">
			<table class="form-table no-margin">
				<tr>
					<th scope="row">
						<?php echo $form->labelEx($role, 'description'); ?>
					</th>
					<td>
						<?php echo $form->textField($role, 'description', array('size' => 45)); ?>
						<?php echo $form->error($role, 'description'); ?>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="section grid_16">
		<div class="block">
			<h2>Permissions</h2>
			<div id="permissions-table"  class="grid_16">
				<?php if (!empty($authItemGroups)): ?>
					<?php foreach ($authItemGroups as $groupName => $authItems): ?>
						<fieldset>
							<legend>
								<?php echo $groupName; ?>
							</legend>
							<?php if (!empty($authItems)): ?>
								<?php foreach ($authItems as $authItem): ?>
									<label for="<?php echo CHtml::getIdByName('operation[' . $authItem['name'] . ']'); ?>">
										<?php echo CHtml::checkBox('operation[' . $authItem['name'] . ']', $authManager->hasItemChild($role->name, $authItem['name']), array('uncheckValue' => 0)); ?>
										<?php echo $authItem['description']; ?>
									</label>
								<?php endforeach; ?>
							<?php endif; ?>
						</fieldset>
					<?php endforeach; ?>
				<?php endif; ?>
			</div>
		</div>
	</div>
	<div class="form_buttons grid_16 clearfix">
		<?php echo GxHtml::submitButton('Save', array('class' => 'link-button green no-margin', 'name' => '')); ?>
		<a href="<?php echo $this->createUrl('roles/index', array('type' => $type)); ?>" class="link-button no-margin">Cancel</a>
	</div>
	<br/>
	<br/>
	<?php $this->endWidget(); ?>
</div>